//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<RenderSet.h>
///	@path	~/src/graphics/
///	@date	2008/04/27
///	@desc	.

#pragma once

#include "xeres.h"

#include "graphics/IDevice.h"
#include "graphics/IBatch.h"
#include "graphics/IModel.h"
#include "graphics/RenderContext.h"

namespace xeres {

	enum RenderSetId
	{
		// Predefined render sets

		/// Renders the whole scene.
		RenderSet_Scene			= 0 ,
		/// Terrain, continues large land.
		RenderSet_Terrain		= 1 ,
		/// Characters, with skeleton animation.
		RenderSet_Character		= 2 ,
		/// Entity, movable models.
		RenderSet_Entity		= 3 ,
		/// Vegetation, instancing small objects.
		RenderSet_Vegetation	= 4 ,
		/// Another static models.
		RenderSet_StaticModel	= 5 ,
		/// Indoor occluders.
		RenderSet_Indoor		= 6 ,
		/// Particles, sprites.
		RenderSet_Particle		= 7 ,
		/// Fogs, volumetric smokes.
		RenderSet_Atmosphere	= 8 ,
		/// Special effects.
		RenderSet_Effect		= 9 ,
		/// Environments, usually sky and clouds and stars.
		RenderSet_Environment	= 10 ,
		/// Custom draw calls.
		RenderSet_DrawCall		= 11 ,
		/// Decals on surfaces.
		RenderSet_Decal			= 12 ,
		//
		RenderSet_last
	};

	/*!	
		\class	RenderSet
		\brief	Manages render sets.
	*/
	class RenderSet : public RenderContext
	{
	protected:

		/// \name Constructor & Destructor
		//@{

		/// \ctor
		RenderSet( void );

		/// \dtor
		~RenderSet( void );

		//@}

		/// \name Initialization & Finalization
		//@{

		/*!
			\brief		Initialize render manager.
		*/
		void Initialize( void );

		/*!
			\brief		Finalize render manager.
		*/
		void Finalize( void );

		//@}

		/// \name Render Manipulation
		//@{

		/// \brief	BeginBatch
		void BeginBatch( void );

		/// \brief	EndBatch
		void EndBatch( void );

		/// \brief	Render custom sets.
		void Render( uint32 sets );

		//@}

	public:

		/// \name Batch Manipulation
		//@{

		/// \brief	Add draw calls.
		void BatchDrawCall( const function<void(RenderContext&)>& dc );

		/// \brief	Add model.
		void BatchModel( RefWeak<IModel> model );

		//@}

	private:

		//@ data
		Ref<IBatch>		m_batches[RenderSet_last];
	};

} // namespace xeres
